package io.renren.modules.medical.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.DoctorInfoUtils;
import io.renren.modules.medical.dao.DoctorInfoDao;
import io.renren.modules.medical.entity.DoctorInfoEntity;
import io.renren.modules.medical.service.DoctorInfoService;
import org.springframework.stereotype.Service;

import java.util.HashMap;

/**
 * @author Luo Sheng
 * @school YiBin university
 * @create 2023-03-29 9:35
 */
@Service("doctorInfoService")
public class DoctorInfoServiceImpl extends ServiceImpl<DoctorInfoDao, DoctorInfoEntity> implements DoctorInfoService {


    @Override
    public DoctorInfoEntity getByUserId(Long userId) {
        LambdaQueryWrapper<DoctorInfoEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(userId != null, DoctorInfoEntity::getUserId, userId);
        return this.getOne(queryWrapper);
    }

    @Override
    public HashMap<String, Object> getLocal() {
        DoctorInfoEntity doctorInfoEntity = DoctorInfoUtils.getDoctorInfo(this);

        HashMap<String, Object> resultMap = new HashMap<>();
        resultMap.put("id", doctorInfoEntity.getId());
        resultMap.put("name", doctorInfoEntity.getName());
        resultMap.put("avatar", doctorInfoEntity.getAvatar());
        resultMap.put("depId", doctorInfoEntity.getDepId());
        return resultMap;
    }



}
